package com.simpleframe.validator.validators;

import com.simpleframe.validator.FieldValidator;

public class EqualToValidator extends FieldValidator{
	
	@Override
	public void validate(Object object) {
		System.out.println("验证是否等于某个字段");
		String fieldName = getFieldName();
		String fieldValue = getFieldValue();
		String value = getValue().replaceAll("'", "");
		//System.out.println(value);
		if(fieldValue!=null && fieldValue.length() > 0 && fieldValue != null && fieldValue.length() > 0 ){
			if(value.startsWith("#")){
				//System.out.println(value.replaceAll("#", ""));
				if(!fieldValue.equals(getFieldValue(value.replaceAll("#", "").replaceAll("_", ".")))){
					addFieldError(fieldName, label + "和" + value + "的输入不一致");
				}
			}
		}
	}
	
}
